package com.wa.util;

import cn.hutool.core.lang.Dict;

/**
 * 用于存储线程上下文数据
 * gary
 */
public class ThreadLocalUtil {
    private static final ThreadLocal<Dict> local = new InheritableThreadLocal<>();

    /**
     * 获取值
     */
    public static Dict get() {
        Dict dict = local.get();
        if (dict == null) {
            dict = new Dict();
            local.set(dict);
        }
        return dict;
    }

    /**
     * 删除值
     */
    public static void remove() {
        Dict dict = local.get();
        if (dict != null) {
            local.remove();
        }
    }
}
